<?php

include '../DB/dbConnection.php';

$result=array();

if ($_POST){
	
	$request_default=2;
	$activate_default=0;
	
	$query_new = 
	$stmt = $conn->prepare("INSERT INTO school (school, name, email, phone, state, city, password, request, activate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
	$stmt->bind_param("sssssssii", $_POST['school'], $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['state'], $_POST['city'], $_POST['passwd'], $request_default,$activate_default);
	$success = $stmt->execute();
	$newId =  $conn->insert_id;
	$stmt->close();
	
	if($success){
		$stmt = $conn->prepare("INSERT INTO exam_config (id,test,main,school_id) VALUES (?,?,?,?)");
		$stmt->bind_param("iiii",$activate_default,$activate_default,$activate_default,$newId);
		$success = $stmt->execute();
		$stmt->close();
	}
	
	$conn->close();
	
	if($success){
		$result['error']='false';
		$result['id']=$newId;
	}
	else
	{
		$result['error']='true';
		$result['id']=$newId;
	}
}
else
{
	$result['error']='true';
}

echo json_encode($result);
?> 
